from django.db import models
from datetime import datetime
# from taggit.managers import TaggableManager

class Article(models.Model):
    
    IS_SPECIE = 0
    IS_INSTALLATION = 1
        
    TYPES_CHOICES = (
        (IS_SPECIE, "Specie"),
        (IS_INSTALLATION, "Installation")                             
    )
    
    title = models.CharField("Title", max_length=100, unique=True )
    slug = models.SlugField("Slug", max_length=100, unique=True, blank=True)
    text = models.TextField("Body")
    image = models.ImageField(upload_to='article_image', blank=True)
    types = models.IntegerField("Types", choices=TYPES_CHOICES)
    created_at = models.DateTimeField("Created at", default=datetime.now)    
#   tags = TaggableManager()
    
    class Meta:
        db_table = "articles"
        verbose_name = ("Article")
        verbose_name_plural = ("Articles")
        ordering = ('-created_at',)
        get_latest_by = 'created_at'
    
    def __unicode__(self):
        return self.title